package com.bb.services.impl;

import java.util.Map;

import org.apache.ibatis.session.SqlSession;

import com.bb.dao.UserDao;
import com.bb.pojo.User;
import com.bb.service.UserService;
import com.bb.util.GetSqlSessionUtil;

public class UserServiceImpl implements UserService{
	
	/*  用户的注册    */
	@Override
	public int userregisters(User user) {
		SqlSession sqlSession = new GetSqlSessionUtil().getSqlSession();
		UserDao mapper = sqlSession.getMapper(UserDao.class);
		int userRegister = mapper.userRegister(user);
		sqlSession.commit();
		return userRegister;
	}
	/*用户的登录*/
	@Override
	public int userlogin(Map map) {
		SqlSession sqlSession = new GetSqlSessionUtil().getSqlSession();
		UserDao mapper = sqlSession.getMapper(UserDao.class);
		User userLogin = mapper.userLogin(map);
		int i = 0;
		if(userLogin != null){
			if(userLogin.getU_pass().equals(map.get("u_pass"))){
				i=1;
			}
		}
		return i;
	}

}
